package net.kazed.nextaction.tools;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import net.kazed.nextaction.R;
import net.kazed.nextaction.database.serialize.BackupFileSummary;
import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class BackupListItemView extends RelativeLayout {

    private DateFormat dateFormat;
    private TextView fieldCreateDate;
    private ImageView itemActionIcon;

    public BackupListItemView(Context androidContext, boolean displayItemActionIcon) {
        super(androidContext);

        LayoutInflater vi = (LayoutInflater) androidContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        vi.inflate(R.layout.backup_list_item, this, true);
        
        dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        fieldCreateDate = (TextView) findViewById(R.id.create_date);
        itemActionIcon = (ImageView) findViewById(R.id.item_action_icon);
        
        if (!displayItemActionIcon) {
            itemActionIcon.setVisibility(INVISIBLE);
        }
    }

    public void updateView(BackupFileSummary backupFileSummary) {
        
        fieldCreateDate.setText(dateFormat.format(backupFileSummary.getCreateDate()));
    }

}
